<?php
$this->sendDebugMessage("roll model start");

$user = $this->userCenter->userList[$ip];

$max = empty($timeout) ? 100:70;
$roll = mt_rand(1,$max);
$rid = $this->userCenter->userList[$ip]->roomID;
$tid = $user->tableID;
$tb = $this->userCenter->roomList[$rid]->tableList[$tid];

if($user->roll > 0)
{

}else{
	$user->roll = $roll;
}
$response = new Response();
$response->event = "SE_ROLL";
$response->body = '{"seatID":"'.$user->seatID.'","roll":'.$roll.',"userID":"'.$user->userID.'"}';
$this->broadcastGroup($response,$this->userCenter->roomList[$user->roomID]->tableList[$user->tableID]->getUserList());

if($tb->rollTime == false)
{
	return;
}

$currentRoll = 0;
$currentSeat = 0;
foreach($tb->seatList as $k=>$v)
{
	$u = $this->userCenter->userList[$v->userID];

	if($u->roll > 0)
	{
		if($currentRoll < $u->roll)
		{
			$currentRoll = $u->roll;
			$currentSeat = $k;
		}else{
			continue;
		}
	}else{
		return;
	}
}

$tb->currentPlayerSeatID = $currentSeat;

$response = new Response();
$response->event = "SE_PLAY_FROM";
$response->body = '{"seatID":"'.$currentSeat.'"}';
$this->broadcastGroup($response,$this->userCenter->roomList[$user->roomID]->tableList[$user->tableID]->getUserList());

$tb->rollTime = false;

$this->sendDebugMessage("roll model end");